package com.cwz.taculture.controller.sign;

import com.cwz.taculture.pojo.UserPojo;
import com.cwz.taculture.service.sign.SignFindByRnumberService;
import com.cwz.taculture.util.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 登录的controller
 */

//@Controller
    @CrossOrigin
@RestController
public class SignFindByRnumberController {
    @Autowired
    private SignFindByRnumberService signFindByRnumberService;
//    登录拿值判断
    @RequestMapping("login/{userName}/{userNumber}/{userPwd}")
    public UserPojo login(@PathVariable("userName") String userName, @PathVariable("userNumber") String userNumber, @PathVariable("userPwd") String userPwd){
        String Pwd = SecurityUtils.sha256Hex(userPwd);
        UserPojo userPojo = signFindByRnumberService.login(userName,userNumber,Pwd);
//        model.addAttribute("login",userPojo);
//        request.getSession().setAttribute("User",userPojo);
        return userPojo;
    }

//    判断用户名是否存在
    @RequestMapping("findRegisterRname/{userName}")
    public String findRegisterRname(@PathVariable("userName") String userName){
        return signFindByRnumberService.findRegisterRname(userName);
    }
//    判断手机号是否存在
    @RequestMapping("findRegisterByRnumber/{userNumber}")
    public String findRegisterByRnumber(@PathVariable("userNumber") String userNumber){
        return signFindByRnumberService.findRegisterByRnumber(userNumber);
    }

}
